<!DOCTYPE html>
<html class="x-admin-sm">
    <head>
        <meta charset="UTF-8">
        <title>管理员列表</title>
        <meta name="renderer" content="webkit">
        <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
        <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
        <link rel="stylesheet" href="./css/font.css">
        <link rel="stylesheet" href="./css/index.css">
        <script src="./lib/layui/layui.js" charset="utf-8"></script>
        <script type="text/javascript" src="./js/index.js"></script>
         <script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>

    </head>
    <body>
        <div class="x-nav">
          <span class="layui-breadcrumb">
            <a href="">首页</a>
            <a href="">演示</a>
            <a>
              <cite>导航元素</cite></a>
          </span>
          <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right" onclick="location.reload()" title="刷新">
            <i class="layui-icon layui-icon-refresh" style="line-height:30px"></i></a>
        </div>
        <div class="layui-fluid">
            <div class="layui-row layui-col-space15">
                <div class="layui-col-md12">
                    <div class="layui-card">
                        <div class="layui-card-body ">
                            <form class="layui-form layui-col-space5">
                              
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="text" name="account"  placeholder="请输入用户名" autocomplete="off" id="account" class="layui-input">
                                </div>
                                <div class="layui-inline layui-show-xs-block">
                                    <input type="button"  value="搜索" class="layui-btn" id="addmiselect" onclick="aaa()" >
                                </div>
                            </form>
                        </div>
                        <div class="layui-card-header">
                            <button class="layui-btn" onclick="xadmin.open('添加红包','添加红包.html',600,400)"><i class="layui-icon"></i>添加</button>
                        </div>
                        <div class="layui-card-body ">
                            <table class="layui-table layui-form">
                              <thead>
                                <tr>
                                 
                                  <th>用户ID</th>
								  <th>红包ID</th>
                                  <th>优惠面值</th>
                                  <th>规则</th>
                                  <th>领取时间</th>
								  <th>过期时间</th>
                                  <th>状态</th>
                                  <th>操作</th>
                              </thead>
                              <tbody id="glytj">
                               
                                
                              </tbody>
                            </table>
                        </div>
                       
                       
                        <div class="layui-card-body " id="fenye">
                           
                        </div>
                    </div>
                </div>
            </div>
        </div> 
    </body>
    <script type="text/javascript">
    	function cha3(){
    			$.ajax({
    				xhrFields:{withCredentials: true},
    					url: "http://localhost:16111/activity/chasuoyou",
    					mimeType: "post",
    					dataType: "json",
    					
    					success: function(date){
    					
    						var str="";
							var menkan="";
							var mj=""
    						for (i in date) { 
    							var time=new Date(date[i].collectiontime);
    							var time2=time.getFullYear()+"-"+(time.getMonth()+1)+"-"+(time.getDate());
    							var time3=new Date(date[i].timedata);
    							var time4=time3.getFullYear()+"-"+(time3.getMonth()+1)+"-"+(time3.getDate());
								if(date[i].threshold==0){
									menkan="无门槛";
									mj="";
								}else {
									menkan="有门槛";
									mj="(满"+date[i].preferentialway +"减"+date[i].parvalue+")";
								}
								if(date[i].status==0){
									zt="未领取"
								}else if(date[i].status==1){
									zt="未使用";
								}else if(date[i].status==2){
									zt="已使用";
								}else if(date[i].status==3){
									zt="已过期";
								}
								
    							str+= "<tr>"+
								"<td>"+date[i].users+"</td>"+
								"<td>"+date[i].id+"</td>"+
								"<td>"+date[i].parvalue.toFixed(2)+"</td>"+
								"<td>"+menkan+mj+"</td>"+
								"<td>"+time2+"</td>"+
								"<td>"+time4+"</td>"+
								"<td>"+zt+"</td>"+
								"<td>"+
								 "<a title=\"编辑\"  onclick=\"xadmin.open('编辑',\'编辑红包.html?id="+date[i].id+"&parvalue="+date[i].parvalue+"&threshold="+date[i].threshold+"&preferentialway="+date[i].preferentialway+"&totalissued="+date[i].totalissued+"\' )\"  href=\"javascript:;\">"+
									                          "<i class=\"layui-icon\"  > &#xe642;</i>"+
									                       "</a>"+
									                        "<a title=\"删除\" onclick=shanchu(\""+date[i].id+"\") href=\"javascript:;\">"+	                 
									                          "<i class=\"layui-icon\"> &#xe640;</i>"+
									                        "</a>"+
															"</td>"+
								"</tr>";   }                     
    		// onclick=bianji(\""+date[i].id+"\",\""+date[i].parvalue+"\",\""+menkan+"\")
    					document.getElementById("glytj").innerHTML=str;
    	
    					},
    				});
    			}
				cha3();
				
				
				function shanchu(id) {
					var id=id;
					alert(id)
					$.ajax({
						xhrFields:{withCredentials: true},
					url: "http://localhost:16111/activity/shanchu",
					mimeType: "post",
					data: {
						id:id
					},
					dataType: "json",
					
						
					success: function(date){
						
						console.log(date);
						if(date == 1){
							alert("删除成功");
						window.location.href="优惠券管理.html";
						}else{
							alert("删除失败");
						}
						
					},
					});
					
				}
		
				
    </script>
</html>